/**
 * 
 */
package tests;

import java.awt.FlowLayout;

import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 * @author masaru-gotou
 *
 */
@SuppressWarnings({ "unused", "serial" })
public class JComboBoxTest extends JPanel {
	private JComboBox combobox;
	
	public JComboBoxTest() {
		super(new FlowLayout());
		combobox = new JComboBox();
		combobox.addItem(new TestItem("item1",1));
		combobox.addItem(new TestItem("item2",2));
		combobox.addItem(new TestItem("item3",3));
		
		add(combobox);
	}
	
	private class TestItem {
		private String name;
		private int value;
		
		public TestItem() {
			this(null,0);
		}
		public TestItem(String name, int value) {
			this.name = name;
			this.value = value;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public int getValue() {
			return value;
		}
		public void setValue(int value) {
			this.value = value;
		}
		@Override
		public String toString() {
			return super.toString();
		}
		
		
	}
	
    private static void createAndShowGUI() {
        //Create and set up the window.
        JFrame frame = new JFrame("JComboBox Test");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //Create and set up the content pane.
        JComboBoxTest newContentPane = new JComboBoxTest();
        newContentPane.setOpaque(true); //content panes must be opaque
        frame.setContentPane(newContentPane);

        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }
	/**
	 * @param args
	 */
	public static void main(String[] args) {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
	}
}
